
package com.tz.tzgw.pc.web.dao;

import com.tz.tzgw.pc.web.model.Menu;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class MenuDao {
    private final JdbcTemplate jdbcTemplate;

    public MenuDao(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    public String[] getPermssByMenuIds(Long[] roleIds) {
        String sql = "SELECT * FROM tz_menu WHERE id IN (?) AND  status = 1 AND visible = 1 AND perms != '' ORDER BY order_num DESC";
        List<Menu> roleMenus = jdbcTemplate.query(sql, new Object[]{roleIds}, new BeanPropertyRowMapper<>(Menu.class));
        return roleMenus.toArray(new String[0]);
    }

}
